package com.whu.waterworks.action;

import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;

import com.opensymphony.xwork2.ActionSupport;
import com.whu.waterworks.model.MyUserDetails;

public class GoToWaterInfoPage extends ActionSupport{

	/**
	 * 
	 */
	private static final long serialVersionUID = -2074011596769465598L;
	/**
	 * 跳转到水情iframe
	 * @return
	 */
	public String gotoWaterInfoPage()
	{
		Authentication  auth = SecurityContextHolder.getContext().getAuthentication();
	     if(auth.getPrincipal() instanceof MyUserDetails)
	     {
	    	 MyUserDetails userDetails = (MyUserDetails)auth.getPrincipal();
	    	 String role = userDetails.getRole();
	    	 System.out.println("&&&&&&&&&&&&&&"+role);
	    	 if("R2".equals(role))//ROLE_R2不能修改
	    	 {	    		
	    		 return "restricted";
	    	 }
	     }
		return SUCCESS;
	}
	/**
	 * 跳转到水质iframe
	 * @return
	 */
	public String gotoWaterQualityPage()
	{
		return SUCCESS;
	}
	/**
	 * 跳转到初始化界面
	 * @return
	 */
	public String gotoInitAllPage()
	{
		return SUCCESS;
	}

}
